---
title: "STAT 672 Lab 1"
author: "Jonathan Schierbaum"
date: "8/30/2021"
output: pdf_document
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)

setwd("C:/Users/jonzh/OneDrive/Phase 2/College/Math/Nonparametric Stats/Labs")
```

## Example 1

```{r q1}
rnorm(100)

temp <- rnorm(100)

length(temp)

hist(temp, 
     main = "One-Hundred Normal (0, 1) Realizations", 
     xlab = "R.V. value")
```

a) **What is in the object temp?**

- 100 draws from a Normal (0,1) distribution.

b) **What is the length of the object temp?** 
- temp is a vector with 100 elements.

c) **What is your informative plot of temp?** 
- I made a histogram showing the frequency of the observed values stored in temp.

## Example 2
```{r q2}
set.seed(1)

bindat <- rbinom(n=10000, size=10, prob=0.8)

hist(bindat, 
     breaks = seq(2, 10, 1), 
     main = "Binomial (10, 0.8) Realizations", 
     xlab = "number of successes (out of 10)", 
     freq = F)

1-pbinom(7, 10, 0.8)
```
a) **What is the probability of making at least 8 out of 10 free throws?**
- $P(X\geq8)=1-P(X\leq7)=0.6778$


## Example 3
```{r q3}
results <- binom.test(15, 25, 0.4, alternative = "greater")

results 

1 - pbinom(14, 25, 0.4)
```
a) **What is the probability of making at least 15 out of 25 free throws?**
- $P(X\geq15)=1-P(X\leq14)=0.0344$

b) **What is your conclusion for this test?**
- The P-value for our observation is low; We would reject the null hypothesis for any $\alpha \leq 0.0344$  

- There is substantial evidence in favor of the alternative hypothesis that the probability of first serve success is greater than 0.4.


## Power Functions
```{r }
# probability of rejecting given null true
1 - pbinom(13, 25, 0.4)
1 - pbinom(13, 25, 0.5)
1 - pbinom(13, 25, 0.9)
```             